package cn.wetcland.urban.framework.controller;

import cn.wetcland.urban.common.AjaxResponse;
import cn.wetcland.urban.framework.service.UtDistrictService;
import cn.wetcland.urban.framework.vo.DistrictListVO;
import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.wetcland.urban.common.AjaxResponse;
import cn.wetcland.urban.framework.service.UtDistrictService;
import cn.wetcland.urban.framework.vo.DistrictListVO;
import cn.wetcland.urban.generator.domain.UtDistrict;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/district")
public class DistrictController {

    @Resource
    public UtDistrictService districtService;

    @GetMapping("/provinceList")
    public AjaxResponse provinceList() {
        DistrictListVO provinceList = districtService.getProvinceList();
        return AjaxResponse.success(provinceList);
    }

    @GetMapping("/cityList")
    public AjaxResponse cityList(@RequestParam Long provinceId) {
        DistrictListVO cityList = districtService.getCityList(provinceId);
        return AjaxResponse.success(cityList);
    }

    @GetMapping("/districtList")
    public AjaxResponse districtList(@RequestParam Long cityId) {
        DistrictListVO districtList = districtService.getDistrictList(cityId);
        return AjaxResponse.success(districtList);
    }

    @GetMapping("/name")
    public AjaxResponse districtName(@RequestParam Long id) {
        UtDistrict byId = districtService.getById(id);
        return AjaxResponse.success(byId);
    }

}
